<?php
	class Model_home extends CI_Model{
		protected $_intro = "tbl_intro";
		protected $_table = "tbl_customer";
		protected $_educa = "tbl_education";
		protected $_contact = "tbl_contact_info";
		protected $_usercontact = "tbl_contact";
		protected $_article = "tbl_articles";
		protected $_link = "tbl_content";
		protected $_linksub = "tbl_content_detail";
		protected $_regions = "tbl_regions";
		public function __construct(){
			parent::__construct();
			$this->load->database();
		}
		public function intro($id){
			$this->db->where("in_id",$id);
			$this->db->order_by("in_order","ASC");
			return $this->db->get($this->_intro)->row_array();
		}
		public function related_intro($id){
			$this->db->order_by("in_order","ASC");
			return $this->db->get($this->_intro)->result_array();
		}
		public function contact(){
			$this->db->where("contact_id","1");
			return $this->db->get($this->_contact)->row_array();
		}
		public function getregion($id){
			$this->db->where("region_id",$id);
			return $this->db->get($this->_regions)->row_array();
		}
		public function add($data){
			$this->db->insert($this->_table,$data);
		}
		public function insert_contact($data){
			$this->db->insert($this->_usercontact,$data);
		}
		public function getlink(){
			return $this->db->get($this->_link)->result_array();
		}
		public function getvallink($id){
			$this->db->where("content_id",$id);
			return $this->db->get($this->_link)->row_array();
		}
		public function count_all_link($id){
			$this->db->where("content_id",$id);
			return $this->db->count_all_results($this->_linksub);
		}
		public function list_all_link($id,$off,$start){
			$this->db->where("content_id",$id);
			$this->db->limit($off,$start);
			return $this->db->get($this->_linksub)->result_array();
		}
		public function article($id){
			$this->db->where("article_id",$id);
			return $this->db->get($this->_article)->row_array();
		}
	}